import * as vscode from 'vscode';
import { cangjie } from './cangjie';
import { registerProvider } from './intellisenses/providers';
import { globalContext } from './intellisenses/globalContext';

export function activate(context: vscode.ExtensionContext) {
    globalContext.instance.initialize();

    context.subscriptions.push(vscode.commands.registerCommand("cj.createProject", () => {
        cangjie.createProject();
    }));

    context.subscriptions.push(vscode.commands.registerCommand("cj.initProject", (fileUri: vscode.Uri) => {
        cangjie.initProject(fileUri);
    }));

    context.subscriptions.push(vscode.commands.registerCommand("cj.dependenciesTools", (fileUri: vscode.Uri) => {
        cangjie.dependenciesTools(context.extensionPath, fileUri);
    }));

    context.subscriptions.push(vscode.commands.registerCommand("cj.updateDependencies", (fileUri: vscode.Uri) => {
        cangjie.updateDependencies();
    }));

    context.subscriptions.push(vscode.commands.registerCommand("cj.buildProject", (fileUri?: vscode.Uri) => {
        cangjie.buildProject();
    }));

    context.subscriptions.push(vscode.commands.registerCommand("cj.buildFile", (fileUri: vscode.Uri) => {
        cangjie.buildFile(fileUri);
    }));

    context.subscriptions.push(vscode.commands.registerCommand("cj.cleanProject", (fileUri?: vscode.Uri) => {
        cangjie.cleanProject();
    }));

    context.subscriptions.push(vscode.commands.registerCommand("cj.about", () => {
        cangjie.showAbout(context.extensionPath);
    }));

    registerProvider(context);

    vscode.window.showInformationMessage("Cangjie Tools is now activate!");
}

export function deactivate() { }
